<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Za清透0感CP免邮试用</title>
</head>

<body>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script src="./jquery-1.11.3.min.js"></script>
    <script src="./jbase64.js"></script>
    <script>
        (function() {


            var hostUrl = "http://www.za.max-marketing.cn";
            var url = window.location.href;
            var base = new Base64();
            var appId = '',
                timestamp, nonceStr = '',
                signature = '';

            $.ajax({
                type: 'POST',
                url: hostUrl + '/web/wechat/getShareData.action',
                data: {
                    url: base.encode(url)
                },
                async: false,
                success: function(result) {
                    appId = result.appId;
                    timestamp = result.timestamp;
                    nonceStr = result.nonceStr;
                    signature = result.signature;
                },
                error: function() {}
            });

            wx.config({
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                appId: appId, // 必填，公众号的唯一标识
                timestamp: timestamp, // 必填，生成签名的时间戳
                nonceStr: nonceStr, // 必填，生成签名的随机串
                signature: signature, // 必填，签名
                jsApiList: [
                    'checkJsApi',
                    'onMenuShareAppMessage', //1.0 分享到朋友
                    'onMenuShareTimeline', //1.0分享到朋友圈
                    'updateAppMessageShareData', //1.4 分享到朋友
                    'updateTimelineShareData' //1.4分享到朋友圈] // 必填，需要使用的JS接口列表
                ]
            });

            wx.ready(function() { //需在用户可能点击分享按钮前就先调用
                var imgUrl = "http://www.za.max-marketing.cn/za1/share_img.png",
                    link = hostUrl, //分享页面链接
                    title = 'Za清透0感CP免邮试用',
                    desc = '清爽一夏 肌肤深呼吸'; //这里请特别注意是要去除html

                wx.onMenuShareAppMessage({
                    title: title,
                    desc: desc, //这里请特别注意是要去除html
                    link: 'http://www.za.max-marketing.cn/web/wechat/index.action',
                    imgUrl: imgUrl,
                    success: function(res) {
                        // saveShareData();
                    },
                    cancel: function(res) {
                        // alert('已取消');
                    }
                });

                wx.onMenuShareTimeline({
                    title: title,
                    desc: desc, //这里请特别注意是要去除html
                    link: link,
                    imgUrl: imgUrl,
                    success: function(res) {
                        saveShareData();
                    },
                    cancel: function(res) {
                        alert('已取消');
                    }
                });
            });

            function saveShareData() {
                $.ajax({
                    type: "post",
                    url: hostUrl + '/web/wechat/saveShareData.action',
                    async: false,
                    data: {
                        type: "1"
                    },
                    success: function(data) {},
                    error: function() {}
                });
                finish();
            }

        })()
    </script>
    <noscript>
    <strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it
        to continue.</strong>
  </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
</body>

</html>